package my.stock.util;

import com.google.common.io.Files;
import com.google.common.io.Resources;
import org.apache.commons.io.Charsets;

import java.io.File;
import java.net.URL;
import java.util.Collections;
import java.util.List;

public class BrowserUserAgent {

    private static List<String> userAgentsWindows = null;

//    static {
//        URL url = Resources.getResource("userAgents_windows");
//        if (url != null) {
//            File file = new File(url.getPath());
//            try {
//                userAgentsWindows = Files.readLines(file, Charsets.UTF_8);
//            } catch (Exception ex) {
//            }
//        }
//    }

    public static String getUserAgentWindows() {
        if (userAgentsWindows == null || userAgentsWindows.size() == 0) {
            return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36";
        }
        Collections.shuffle(userAgentsWindows);
        return userAgentsWindows.get(0);
    }
}
